<template>
  <div>
    <div>
      <img
        src="https://scpic.chinaz.net/files/pic/pic9/202003/zzpic23514.jpg"
        alt=""
      />
      <p :style="{ backgroundColor: con }" @click="btn">{{ title }}</p>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      title: "这是一个孤独可怜的狗啊",
      con: "",
    };
  },
  methods: {
    btn() {
      this.con = `rgba(${Math.floor(Math.random() * 256)},${Math.floor(
        Math.random() * 256
      )},${Math.floor(Math.random() * 256)},${Math.floor(Math.random() * 256)}`;
    },
  },
};
</script>

<style scoped>
div {
  display: inline-block;
  text-align: center;

  border: 1px solid #000;
}
</style>